import java.util.Scanner;

public class PrefixSum {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        // long[] nums = new long[n + 1];
        // for (int i = 1; i < n + 1; i++) {
        //     nums[i] = in.nextLong();
        // }
        long[] dp = new long[n + 1];
        for (int i = 1; i < n + 1; i++) {//将nums的初始化与dp的初始化合二为一
            dp[i] = dp[i - 1] + in.nextLong();
        }
        // initDP(dp, nums, n);
        // 注意 hasNext 和 hasNextLine 的区别
        while (q > 0) { // 注意 while 处理多个 case
            int left = in.nextInt();
            int right = in.nextInt();
            System.out.println(dp[right] - dp[left - 1]);
            q--;
        }
    }

    public static void initDP(long[] dp, long[] nums, int n) {
        for (int i = 1; i < n + 1; i++) {
            dp[i] = dp[i - 1] + nums[i];
        }
    }
}
